//
//  PlayerNode.swift
//  G001
//
//  Created by remy on 2023/1/12.
//

class PlayerNode: SKSpriteNode {
    
    static let NODE_NAME: String = PlayerNode.metaTypeName
    static let NODE_SIZE: CGSize = CGSize(width: 40, height: 40)
    
    convenience init() {
        self.init(color: FlatColor.sunflower, size: PlayerNode.NODE_SIZE)
        
        let physicsBody = SKPhysicsBody(rectangleOf: self.size)
        physicsBody.isDynamic = true
        physicsBody.allowsRotation = false
        physicsBody.categoryBitMask = PhysicsCategories.player.rawValue
        physicsBody.contactTestBitMask = PhysicsCategories.enemy.rawValue | PhysicsCategories.block.rawValue
        physicsBody.collisionBitMask = physicsBody.contactTestBitMask
//        physicsBody.collisionBitMask = 0
        self.physicsBody = physicsBody
        self.name = PlayerNode.NODE_NAME
        self.zPosition = ZPositionLevel.player.rawValue
    }
}

class FlowNode: SKSpriteNode {
    
    static let NODE_NAME: String = FlowNode.metaTypeName
    static let NODE_SIZE: CGSize = CGSize(width: 40, height: 40)
    
    convenience init() {
        self.init(color: FlatColor.pumpkin, size: FlowNode.NODE_SIZE)
        
        let physicsBody = SKPhysicsBody(rectangleOf: self.size)
        physicsBody.isDynamic = true
        physicsBody.allowsRotation = true
        physicsBody.categoryBitMask = PhysicsCategories.enemy.rawValue
        physicsBody.contactTestBitMask = PhysicsCategories.enemy.rawValue | PhysicsCategories.player.rawValue | PhysicsCategories.block.rawValue
        physicsBody.collisionBitMask = physicsBody.contactTestBitMask
        self.physicsBody = physicsBody
        self.name = FlowNode.NODE_NAME
        self.zPosition = ZPositionLevel.moving.rawValue
    }
}
